package com.cskaoyan.wordmemorize.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cskaoyan.wordmemorize.dao.entity.UserVocBoundStatisticsDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserVocBoundStatisticsMapper extends BaseMapper<UserVocBoundStatisticsDO> {

    UserVocBoundStatisticsDO findByUserId(Long userId);
    @Select("SELECT * FROM user_voc_bound_statistics WHERE user_id = #{userId}")
    UserVocBoundStatisticsDO selectByUserId(Long userId);

    @Update("UPDATE user_voc_bound_statistics " +
            "SET total = total + #{exchangeVocCount} " +", pay = pay + #{exchangeVocCount} "+
            "WHERE user_Id = #{userId}")
    int updateByUserId(@Param("exchangeVocCount") int exchangeVocCount,
                       @Param("userId") Long userId);
}
